package com.tencreat.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum AfterSaleStatus {
    /**
     * 售后状态枚举
     * ，0是可申请，1是用户已申请，2是管理员审核通过，3是管理员退款成功，4是管理员审核拒绝，5是用户已取消
     */
    CAN_APPLY(0,"无售后"),
    ALREADY_APPLIED(1,"已申请"),
    BUYER_DEAL(2,"待买家处理"),// 买家上传物流
    DEL_PAY(3,"退款成功"),//
    DAI_CENTXT(4,"审核拒绝"),
    CANCELLED(5,"用户已取消"),
    WAIT_RECEIVED(8,"退款退货中"),// 买家上传物流后，平台处理

    ;
    AfterSaleStatus(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @EnumValue
    private final int value;
    @JsonValue
    private final String desc;

    /**
     * 单个枚举的展示
     */
    @Override
    public String toString() {
        return value + "-" + desc;
    }

    public static String getName(Integer status){
        for (AfterSaleStatus s:AfterSaleStatus.values()) {
            if (s.getValue() == status){
                return s.getDesc();
            }
        }
        return null;
    }
}
